package com.didispace;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import rx.Observable;
import rx.Subscriber;

// 在该示例中，创建了一个简单的事件源 observable， 一个对事件传递内容输出的订阅者 subscriber，
// 通过 observable.subscribe(subscriber) 来触发事件的发布。
@SpringBootApplication
public class ObservableSubscribersApplication {

	public static void main(String[] args) {
		// 创建事件源observable
		Observable<String> observable = Observable.create(new Observable.OnSubscribe<String>() {
			@Override
			public void call(Subscriber<? super String> subscriber) {
				subscriber.onNext("Hello RxJava");
				subscriber.onNext("I am程序猿DD");
				subscriber.onCompleted();
			}
		});

		// 创建订阅者subscriber
		Subscriber<String> subscriber = new Subscriber<String>() {
			@Override
			public void onCompleted() {
			}

			@Override
			public void onError(Throwable e) {
			}

			@Override
			public void onNext(String s) {
				System.out.println("Subscriber : " + s);

			}
		};

		// 订阅
		observable.subscribe(subscriber);
	}
}

// "D:\Program Files\Java\jdk1.8.0_211\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\JetBrains\IntelliJ IDEA 2019.3\lib\idea_rt.jar=62435:D:\JetBrains\IntelliJ IDEA 2019.3\bin" -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\jacob.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;F:\BOOK\2022\Spring Cloud微服务实战\SpringCloudBook-master\chapter05\observable-subscribers\target\classes;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter-web\1.3.7.RELEASE\spring-boot-starter-web-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter\1.3.7.RELEASE\spring-boot-starter-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot\1.3.7.RELEASE\spring-boot-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.3.7.RELEASE\spring-boot-autoconfigure-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.3.7.RELEASE\spring-boot-starter-logging-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\ch\qos\logback\logback-classic\1.1.7\logback-classic-1.1.7.jar;C:\Users\嘉\.m2\repository\ch\qos\logback\logback-core\1.1.7\logback-core-1.1.7.jar;C:\Users\嘉\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.21\jcl-over-slf4j-1.7.21.jar;C:\Users\嘉\.m2\repository\org\slf4j\jul-to-slf4j\1.7.21\jul-to-slf4j-1.7.21.jar;C:\Users\嘉\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.21\log4j-over-slf4j-1.7.21.jar;C:\Users\嘉\.m2\repository\org\yaml\snakeyaml\1.16\snakeyaml-1.16.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\1.3.7.RELEASE\spring-boot-starter-tomcat-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\8.0.36\tomcat-embed-core-8.0.36.jar;C:\Users\嘉\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.0.36\tomcat-embed-el-8.0.36.jar;C:\Users\嘉\.m2\repository\org\apache\tomcat\embed\tomcat-embed-logging-juli\8.0.36\tomcat-embed-logging-juli-8.0.36.jar;C:\Users\嘉\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.0.36\tomcat-embed-websocket-8.0.36.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter-validation\1.3.7.RELEASE\spring-boot-starter-validation-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\hibernate\hibernate-validator\5.2.4.Final\hibernate-validator-5.2.4.Final.jar;C:\Users\嘉\.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\嘉\.m2\repository\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;C:\Users\嘉\.m2\repository\com\fasterxml\classmate\1.1.0\classmate-1.1.0.jar;C:\Users\嘉\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.6.7\jackson-databind-2.6.7.jar;C:\Users\嘉\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.6.7\jackson-annotations-2.6.7.jar;C:\Users\嘉\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.6.7\jackson-core-2.6.7.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-web\4.2.7.RELEASE\spring-web-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-aop\4.2.7.RELEASE\spring-aop-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-beans\4.2.7.RELEASE\spring-beans-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-context\4.2.7.RELEASE\spring-context-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-webmvc\4.2.7.RELEASE\spring-webmvc-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-expression\4.2.7.RELEASE\spring-expression-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\spring-core\4.2.7.RELEASE\spring-core-4.2.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-starter-eureka\1.1.5.RELEASE\spring-cloud-starter-eureka-1.1.5.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-starter\1.1.1.RELEASE\spring-cloud-starter-1.1.1.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-context\1.1.1.RELEASE\spring-cloud-context-1.1.1.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\security\spring-security-crypto\4.0.4.RELEASE\spring-security-crypto-4.0.4.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-commons\1.1.1.RELEASE\spring-cloud-commons-1.1.1.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\security\spring-security-rsa\1.0.1.RELEASE\spring-security-rsa-1.0.1.RELEASE.jar;C:\Users\嘉\.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.47\bcpkix-jdk15on-1.47.jar;C:\Users\嘉\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.47\bcprov-jdk15on-1.47.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-netflix-core\1.1.5.RELEASE\spring-cloud-netflix-core-1.1.5.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-netflix-eureka-client\1.1.5.RELEASE\spring-cloud-netflix-eureka-client-1.1.5.RELEASE.jar;C:\Users\嘉\.m2\repository\com\netflix\eureka\eureka-client\1.4.10\eureka-client-1.4.10.jar;C:\Users\嘉\.m2\repository\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;C:\Users\嘉\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\嘉\.m2\repository\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;C:\Users\嘉\.m2\repository\com\netflix\archaius\archaius-core\0.7.4\archaius-core-0.7.4.jar;C:\Users\嘉\.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;C:\Users\嘉\.m2\repository\com\netflix\servo\servo-core\0.10.1\servo-core-0.10.1.jar;C:\Users\嘉\.m2\repository\com\netflix\servo\servo-internal\0.10.1\servo-internal-0.10.1.jar;C:\Users\嘉\.m2\repository\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;C:\Users\嘉\.m2\repository\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;C:\Users\嘉\.m2\repository\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;C:\Users\嘉\.m2\repository\org\apache\httpcomponents\httpclient\4.5.2\httpclient-4.5.2.jar;C:\Users\嘉\.m2\repository\org\apache\httpcomponents\httpcore\4.4.5\httpcore-4.4.5.jar;C:\Users\嘉\.m2\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\嘉\.m2\repository\com\google\inject\guice\4.0\guice-4.0.jar;C:\Users\嘉\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\嘉\.m2\repository\com\netflix\governator\governator-api\1.12.10\governator-api-1.12.10.jar;C:\Users\嘉\.m2\repository\com\netflix\eureka\eureka-core\1.4.10\eureka-core-1.4.10.jar;C:\Users\嘉\.m2\repository\com\amazonaws\aws-java-sdk-core\1.11.18\aws-java-sdk-core-1.11.18.jar;C:\Users\嘉\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-cbor\2.6.6\jackson-dataformat-cbor-2.6.6.jar;C:\Users\嘉\.m2\repository\com\amazonaws\aws-java-sdk-ec2\1.11.18\aws-java-sdk-ec2-1.11.18.jar;C:\Users\嘉\.m2\repository\com\amazonaws\aws-java-sdk-autoscaling\1.11.18\aws-java-sdk-autoscaling-1.11.18.jar;C:\Users\嘉\.m2\repository\com\amazonaws\aws-java-sdk-sts\1.11.18\aws-java-sdk-sts-1.11.18.jar;C:\Users\嘉\.m2\repository\com\amazonaws\aws-java-sdk-route53\1.11.18\aws-java-sdk-route53-1.11.18.jar;C:\Users\嘉\.m2\repository\com\netflix\governator\governator\1.12.10\governator-1.12.10.jar;C:\Users\嘉\.m2\repository\com\netflix\governator\governator-core\1.12.10\governator-core-1.12.10.jar;C:\Users\嘉\.m2\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\Users\嘉\.m2\repository\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;C:\Users\嘉\.m2\repository\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;C:\Users\嘉\.m2\repository\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-starter-archaius\1.1.5.RELEASE\spring-cloud-starter-archaius-1.1.5.RELEASE.jar;C:\Users\嘉\.m2\repository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;C:\Users\嘉\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\嘉\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Users\嘉\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;C:\Users\嘉\.m2\repository\org\springframework\cloud\spring-cloud-starter-ribbon\1.1.5.RELEASE\spring-cloud-starter-ribbon-1.1.5.RELEASE.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon\2.2.0\ribbon-2.2.0.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon-transport\2.2.0\ribbon-transport-2.2.0.jar;C:\Users\嘉\.m2\repository\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;C:\Users\嘉\.m2\repository\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;C:\Users\嘉\.m2\repository\com\netflix\hystrix\hystrix-core\1.5.3\hystrix-core-1.5.3.jar;C:\Users\嘉\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.7\HdrHistogram-2.1.7.jar;C:\Users\嘉\.m2\repository\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;C:\Users\嘉\.m2\repository\io\netty\netty-codec-http\4.0.27.Final\netty-codec-http-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-codec\4.0.27.Final\netty-codec-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-handler\4.0.27.Final\netty-handler-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-transport-native-epoll\4.0.27.Final\netty-transport-native-epoll-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-common\4.0.27.Final\netty-common-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-buffer\4.0.27.Final\netty-buffer-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\io\netty\netty-transport\4.0.27.Final\netty-transport-4.0.27.Final.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon-core\2.2.0\ribbon-core-2.2.0.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon-httpclient\2.2.0\ribbon-httpclient-2.2.0.jar;C:\Users\嘉\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\嘉\.m2\repository\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon-loadbalancer\2.2.0\ribbon-loadbalancer-2.2.0.jar;C:\Users\嘉\.m2\repository\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;C:\Users\嘉\.m2\repository\io\reactivex\rxjava\1.1.5\rxjava-1.1.5.jar;C:\Users\嘉\.m2\repository\com\netflix\ribbon\ribbon-eureka\2.2.0\ribbon-eureka-2.2.0.jar;C:\Users\嘉\.m2\repository\org\slf4j\slf4j-api\1.7.21\slf4j-api-1.7.21.jar;C:\Users\嘉\.m2\repository\com\thoughtworks\xstream\xstream\1.4.2\xstream-1.4.2.jar;C:\Users\嘉\.m2\repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;C:\Users\嘉\.m2\repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-starter-actuator\1.3.7.RELEASE\spring-boot-starter-actuator-1.3.7.RELEASE.jar;C:\Users\嘉\.m2\repository\org\springframework\boot\spring-boot-actuator\1.3.7.RELEASE\spring-boot-actuator-1.3.7.RELEASE.jar" com.didispace.ObservableSubscribersApplication
// 		Subscriber : Hello RxJava
// 		Subscriber : I am程序猿DD